/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.openbravo.pos.util;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;

/**
 *
 * @author Administrator
 */
public class JPanelDrawing extends JPanel {
        private Image img;

        public JPanelDrawing(Image img) {
            this.img = img;
            setLayout(null);
        }

        protected void paintComponent (Graphics g) {
            super.paintComponent(g);
            if (img != null) {
                g.drawImage(img, 0, 0, this);
            }
        }

        public Dimension getPreferredSize() {
            return (img == null)
                ? new Dimension(640, 480)
                : new Dimension(img.getWidth(this), img.getHeight(this));
    }

        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    }
